package xyz.xtt.admin.constants;

import java.util.Arrays;
import java.util.Objects;

/**
 * @author huqibo
 * 
 *         资产类型枚举
 */
public enum SellPatternEnum {
	/**
	 * 售价
	 */
	NORMAL(0, "不出售"),
	/**
	 * 一口价
	 */
	BUY_NOW_PRICE(1, "出售"),
	/**
	 * 出价
	 */
	BID_PRICE(2, "出价"),
	/**
	 * 租赁
	 */
	LEASE_PRICE(3, "租赁"),
	/**
	 * 寄售
	 */
	CONSIGNMENT(4, "寄售"),
	/**
	 * 赠送
	 */
	GIVE_AWAY(5, "赠送"),
	/**
	 * 拍卖
	 */
	AUCTION(6, "拍卖"),
	/**
	 * 铸造
	 */
	MINT(7, "铸造");

	private int code;
	private String desc;

	// 构造函数
	SellPatternEnum(int code, String desc) {
		this.code = code;
		this.desc = desc;
	}

	public int code() {
		return code;
	}

	// 获取描述
	public String desc() {
		return desc;
	}

	public static boolean checkType(String checkType) {
		return Arrays.asList(SellPatternEnum.values()).stream().anyMatch(x -> Objects.equals(x.name(), checkType));
	}

	public static SellPatternEnum convert(String checkType) {
		return Arrays.asList(SellPatternEnum.values()).stream().filter(x -> Objects.equals(x.name(), checkType)).findFirst().orElse(null);
	}

	public static SellPatternEnum queryConvert(int checkType) {
		return Arrays.stream(SellPatternEnum.values()).filter(x -> Objects.equals(x.code(), checkType))
				.findFirst()
				.orElse(null);
	}

}
